From 560f4dc7f29e3c5f79728bc01b2dd4828e55b673 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Mon, 12 Apr 2010 07:22:16 +0100 Subject: [PATCH] libxc: Flush I/O before xc_domain_save completion The final, flushing call to discard_file_cache also discards any errors from fsync. Call fsync explicitly before leaving, to check if all VM memory actually made it to the disk. Signed-off-by: Daniel Stodden --- tools/libxc/xc_domain_save.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/libxc/xc_domain_save.c b/tools/libxc/xc_domain_save.c index 2334b49c07..cb98374e02 100644 --- a/tools/libxc/xc_domain_save.c +++ b/tools/libxc/xc_domain_save.c @@ -1764,6 +1764,13 @@ int xc_domain_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters, goto out; } + /* Flush last write and check for errors. */ + if ( fsync(io_fd) && errno != EINVAL ) + { + PERROR("Error when flushing state file"); + goto out; + } + /* Success! */ rc = 0; -- 2.30.2